﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using Ppt = Microsoft.Office.Interop.PowerPoint;
using DataFactory;

namespace ObjectModel.PowerPoint.New
{
    public class PPTSerializableCollection<T> : ObservableCollection<T>
    {
        PPTSerializer mSerializer = new PPTSerializer();

        public void SerializeToPresentation(Ppt.Presentation pres, string xmlRootName)
        {
            if (this.Count > 0)
                mSerializer.SerializeToPresentation(pres, this, xmlRootName);
        }

        public static PPTSerializableCollection<T> DeserializeFromPresentation(Ppt.Presentation pres, string xmlRootName)
        {
            if (PPTSerializer.ContainsXMLParts(pres, xmlRootName))
                return PPTSerializer.DeserializeAll<PPTSerializableCollection<T>>(pres, xmlRootName)[0];

            return null;
        }
    }
}
